import book.Book;
import book.BookList;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
import user.Admin;
import user.Normal;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a1227
 * Date: 2022-10-04
 * Time: 11:10
 */

public class Main {
    public static User login(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的名字:>");
        String name = scanner.nextLine();
        System.out.println("请选择您的身份:> 管理员 -> 1 / 普通用户 -> 0");
        int choice = scanner.nextInt();
        if(choice == 1){
            return new Admin(name);
        }else{
            return new Normal(name);
        }
    }
    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = login();//向上转型->发生多态
        while(true){
            int choice = user.menu();//子类重写了父类的抽象方法，所以调用子类重写后的方法
            user.doWork(choice,bookList);
        }
    }
}
